# -*- coding: utf-8 -*-
"""
 @Time    : 2021/1/20 下午6:29
 @Author  : tgy
 你需要通过指定的文本模式去检查字符串的开头或者结尾，比如文件名后缀，URL Scheme 等等。
"""
from urllib.request import urlopen


def test01():
    ...
    # ''.startswith()
    url = 'ftp://www.baidu.com'
    print(url.startswith(['http','ftp']))


def test02():
    ...
    #
    print(urlopen('http://www.baidu.com').read().decode('utf-8'))


def read(urls):
    ...
    for url in urls:
        # 如果要传递多个值，必须是元组
        if url.startswith(('http:', 'https:', 'ftp:')):
            ...
            print(urlopen(url).read().decode('utf-8'))
        else:
            with open(url,mode='rt',encoding='utf-8') as f:
                print(f.read())



if __name__ == '__main__':
    ...
    # test02()
    read(['http://www.baidu.com','./2.1 使用多个界定符分割字符串.py'])
